package entity

import (
	"time"

	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//PHXWDR 短贷宝导入
type PHXWDR struct {
	ID     int        `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHYF   int        `gorm:"column:KHYF"`
	XH     int        `gorm:"column:XH"`
	ZZJGM  string     `gorm:"column:ZZJGM"`
	KHMC   string     `gorm:"column:KHMC"`
	JJH    string     `gorm:"column:JJH"`
	SX     string     `gorm:"column:SX"`
	QYGM   string     `gorm:"column:QYGM"`
	QSR    *time.Time `gorm:"column:QSR;type:date"`
	DQR    *time.Time `gorm:"column:DQR;type:date"`
	TS     float64    `gorm:"column:TS"`
	YE     float64    `gorm:"column:YE"`
	ZXLL   float64    `gorm:"column:ZXLL"`
	JYDW   string     `gorm:"column:JYDW"`
	JYDWBL float64    `gorm:"column:JYDWBL"`
	XDGC   string     `gorm:"column:XDGC"`
	BM     string     `gorm:"column:BM"`
	BL     float64    `gorm:"column:BL"`
	DRJG   string     `gorm:"column:DRJG"`
}

//TableName 短贷宝导入
func (PHXWDR) TableName() string {
	return "T_BASE_YXFY_PHXW_DTIP"
}

//PHXWDRAfterImport 导入后执行分户处理
func PHXWDRAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	prams := make([]interface{}, 1)
	prams[0] = params["KHYF"]
	tx.Exec("EXEC UP_BASE_YXFY_PHXW_DTIP ?", prams...)
	return nil
}

//PHXWDREF 返回结构体
func PHXWDREF() base.EntityFunc {
	return func() interface{} {
		entity := PHXWDR{}
		return &entity
	}
}

//PHXWDRESF 返回结构体数组
func PHXWDRESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []PHXWDR
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("PHXWDR", base.NewDefaultDao(PHXWDREF(), PHXWDRESF(), nil))
	base.SetAfterCallBack("PHXWDR", PHXWDRAfterImport)
}
